
/**
 * 操作日志列表
 **/
function loadData() {
    $("#jqGrid").jqGrid($.extend(jqGrids.defaults, {
        url: base + '/operateLog/view/list',
        colNames: ['系统编码', '操作用户', '参数', '标签', '方法', '备注','IP', '创建时间'],
        colModel: [
            {name: 'appCode', index: 'appCode', sortable: false},
            {name: 'user', index: 'user', sortable: false},
            {name: 'params', index: 'params', sortable: false},
            {name: 'tag', index: 'tag'},
            {name: 'method', index: 'method'},
            {name: 'note', index: 'note'},
            {name: 'ip', index: 'ip'},
            {name: 'createTime', index: 'createTime', formatter: tools.formatDate}
        ],
        rowNum: 100,
        rowList: [100, 150, 200],
        multiselect: false
    }));
}

/**邮件查询*/
function doSearch() {
    $("#jqGrid").jqGrid('setGridParam', {
        datatype: 'json',
        postData: $("#search-form").serialize(), //发送数据
        page:0
    }).trigger("reloadGrid"); //重新载入
}

function doMailAccountAdd(id) {
    var url = tools.getContextPath() + "/operateLog/uc/edit?id=" + id + "&type=add";
    window.location.href = url;
}
function doMailAccountEdit(id) {
    var url = tools.getContextPath() + "/operateLog/uc/edit?id=" + id + "&type=edit";
    window.location.href = url;
}


/**
 *mailaccount删除
 */
function doMailTemplateDelete() {
    var ids = $('#jqGrid').jqGrid('getGridParam', 'selarrrow');
    if (ids.length <= 0) {
        $.messager.alert("请选择需要删除的数据项");
        return;
    }
    var url = tools.getContextPath() + "/mail/template/dh/delete";
    $.messager.confirm("你确定要删除选中的记录吗?", function (ck) {
        if (ck) {
            $.getJSON(url, {ids: ids}, function (data) {
                $.messager.alert0({selector: "#indexAlert", type: data.code, html: data.message});
                if (data && data.code == 'SUCCESS') {
                    $("#jqGrid").trigger("reloadGrid");
                }
            });
        }
    })
}


function doMailAccountSubmit(type) {
    if (!formCheck().form()) {
        return;
    }
    var url;

    if ("add" == type) {
        url = base + "/mail/account/sk/insert";
    } else {
        url = base + "/mail/account/uc/update";
    }
    $.post(url, $("#editForm").serialize(), function (data) {
        $.messager.alert0({selector: "#editAlert", type: data.code, html: data.message});
        if (data && data.code == 'SUCCESS') {
            tools.goto(base + "/mail/account/view/index", 500);
        }
    }, "json");

}


function formCheck() {
    return $('#editForm').validate({
        rules: {
            appCode: {
                required: true
            },
            username: {
                required: true
            },
            host: {
                email: true
            },
            password: {
                required: true
            },
            description: {
                maxlength: [100]
            }
        }
    });
}

